import org.junit.Test;

import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
import java.util.Arrays;
import java.util.List;

public class Test01 {

    public int[] solve (int n, int m, int[] a) {
        // write code here
        if(a.length <= 1) return a;
        if(m > n) m = m % n;
        if(m % 2 == 0) {
            // 两次
            insertNext(0, n/2, a, n, m);
            insertNext(1, n/2, a, n, m);
        } else {
            // 一次
            insertNext(0, n, a, n, m);
        }
        return a;
    }


    public void insertNext(int curIndex, int count, int[] a, int n, int m) {
        int curValue = a[curIndex];
        int nextIndex = (curIndex + m) % n;
        int nextValue = a[nextIndex];
        for(int i=0; i<count; i++) {
            a[nextIndex] = curValue;
            curIndex = nextIndex;
            curValue = nextValue;
            nextIndex = (curIndex + m) % n;
            nextValue = a[nextIndex];
        }
    }

    @Test
    public void test_01() {
        int[] a = {1,2,3,4,5,6};
        int[] b = solve(6, 7, a);
        System.out.println(Arrays.toString(b));
    }

    public static void main(String[] args) {
        List<GarbageCollectorMXBean> beans = ManagementFactory.getGarbageCollectorMXBeans();
        for (GarbageCollectorMXBean bean : beans) {
            System.out.println(bean.getName());
        }
    }

    @Test
    public void test_90(){
        double yearSalary = 160000;
        double shui_01 = 36000 * 0.03;
        double shui_02 = (144000 - 36000) * 0.1;
        double shui_03 = (160000 - 144000) * 0.2;
        System.out.println(shui_01);
        System.out.println(shui_02);
        System.out.println(shui_03);
        double yearShould = shui_01 + shui_02 + shui_03;
        System.out.println(yearShould);
    }


}
